<template>
	<view class="pt24 ">
		<view v-if="list.length==0">
			<u-gap height="80"></u-gap>
			<u-empty mode="data" text="无数据"></u-empty>
		</view>
		<view class="pl24 pr24 pb24 " v-for="(item,index) in list" :key="index">
			<view class="bgfff path-card ">
				<view class="pt24 pl24 pr24 ">
					<view>
						<view class="h80 dsf alc bb">
							<view class="fz30  pl24 ">{{item.title}}</view>
						</view>
						<view class=" pb24 ">
							<view class="pt30 pl24 pb30 bb">
								<!-- 装货 -->
								<view v-if="item.address.deliveAddress" class="dsf alc pb24 relative">
									<view class="bdra50b bg0083FE pretend absolute t0">装</view>
									<view class="fz28 col666 pl30 address ml20">
										
										<view class="address-title ">{{item.address.deliveAddress.mapAddress}}
										</view>
										<view class="address-desc pt10 pb10">
											{{item.address.deliveAddress.mapAddressDetail}}
										</view>
										<view class="address-desc ">
											用户名：{{item.address.deliveAddress.userName}}</view>
									</view>
								</view>
								<!-- 卸货 -->
								<view v-for="(row,idx) in item.address.receiveAddress" class="dsf alc pb24 relative">
									<view class="bdra50b bgFD6901 pretend absolute t0">卸</view>
									<view class="fz28 col666 pl30 address ml20">
										<view class="address-title ">{{row.mapAddress}}
										</view>
										<view class="address-desc ">
											{{row.mapAddressDetail}}
										</view>
										<view class="address-desc ">
											用户名：{{row.userName}}</view>
									</view>
								</view>

							 

							</view>
						</view>
					</view>
					<view class="pb20 dsf alc jcfe ">
						<view @click="$go('newaddress/address/editpath?id='+item.id)" class="bd999 pl30 pr30 pt15 pb15 bdra10 dsf alc  button-icon "
							style="box-shadow:0 0 20rpx rgba(0,0,0,.2);">
							<view class="fz30 col999 pl10 ">编辑</view>
						</view>
						<view @click="sDel=true;act_item=item" class="bd999 pl30 pr30 pt15 pb15 bdra10 dsf alc button-icon ml30"
							style="box-shadow:0 0 20rpx rgba(0,0,0,.2);">
							<view class="fz30 col999 pl10 ">删除</view>
						</view>
						<view v-if="param.is_use==1" @click="choose(item)" class="bg0083FE pl30 pr30 pb15 pt15 bdra10 dsf alc  ml30 button-icon ">
							<view class="fz30 colfff pl10 ">选择</view>
						</view>
					
					</view>
				</view>
			</view>
		</view>
		<!--删除弹窗-->
		<u-modal :show="sDel" cancelText="暂不删除" @cancel="sDel=false" @confirm="comDel" :showCancelButton="true"
			closeOnClickOverlay class="box">
			<view class="tip-text pt-30 pb-30 fz30">
				确定删除？
			</view>
		</u-modal>
		<!--添加按钮-->
		<view class="add-box">
			<u-tabbar inactiveColor="#fff" :border="false">
				<u-tabbar-item @click="$go('newaddress/address/editpath')" text="添加路线"></u-tabbar-item>
			</u-tabbar>
		</view>
	</view>

</template>

<script>
	export default {
		data() {
			return {
				keyword: "",
				list: [],
				type: "",
				badgeStyle: "top:6px;font-size:60px;",
				param: {},
				last_page: 0,
				sDel:false,
				act_item:{},
				param:{}
			}
		},
		onReachBottom() {
			this.param.page++;
			if (this.param.page > this.last_page) {
				return;
			}
			this.getList();
		},
		onLoad(e) {
			this.param=e;
		},
		onShow() {
			this.getList();
		},

		methods: {
			getList() {
				this.$api['get']('user/get-route-address', this.param).then(res => {
					if (res.code == 200) {
						this.list = res.data;
					}
				});
			},
			comDel(){
				this.$api['del']('user/delete-address/'+this.act_item.id, {}).then(res => {
					if (res.code == 200) {
						this.sDel=false;
						this.$toast({
							title: "删除成功"
						});
						this.param.page = 1;
						this.getList();
					}
				});
			},
			choose(row){
				console.log(row,"==row===");
				this.$store.commit("getDelive", row.address.receiveAddress);
			    this.$store.commit("getReceive", row.address.deliveAddress);
				uni.navigateTo({
					url: "/pages/index/index"
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	page {
		background-color: #eef2fd
	}

	.adderss-title {
		background-color: #eaf6fd
	}

	.path-card {
		border-radius: 20upx
	}

	.path-card .path-title {
		color: #50abff;
		font-size: 32upx;
		font-weight: 700
	}

	.path-card .pretend,
	.path-card .through {
		color: #fff;
		font-size: 20upx;
		height: 36upx;
		line-height: 36upx;
		margin-right: 20upx;
		text-align: center;
		width: 36upx
	}

	.path-card .through {
		background-color: #9d9d9d
	}

	.path-card .discharge {
		color: #fff;
		font-size: 20upx;
		height: 36upx;
		line-height: 36upx;
		margin-right: 20upx;
		text-align: center;
		width: 36upx
	}

	.path-card .address .address-title {
		font-weight: 700
	}

	.path-card .address .address-desc {
		color: #9d9d9d;
		font-size: 24upx
	}

	.path-card .button-icon {
		font-size: 26upx
	}
</style>